package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Program: day57-leadnews
 * @Description:
 * @Data: 2022/8/4 15:15
 **/
@Api(value = "行为服务API")
@RestController
@RequestMapping("/api/v1/")
public class BehaviorController {

    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation("点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @ApiOperation("阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @ApiOperation("不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation("收藏功能")
    @PostMapping("/collection_behavior")
    public ResponseResult collectionBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @ApiOperation("app文章关系展示功能")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult articleBehavior(@RequestBody ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
